#include "FPSetup.h"
#include <float.h>
#include <stdio.h>

void se_fe_trans_func(unsigned int ecode, struct _EXCEPTION_POINTERS*)
{
	switch (ecode) 
	{
	case EXCEPTION_FLT_DENORMAL_OPERAND:
		throw fe_denormal_operand();
	case EXCEPTION_FLT_DIVIDE_BY_ZERO:
		throw fe_divide_by_zero();
	case EXCEPTION_FLT_INEXACT_RESULT:
		throw fe_inexact_result();
	case EXCEPTION_FLT_INVALID_OPERATION:
		throw fe_invalid_operation();
	case EXCEPTION_FLT_OVERFLOW:
		throw fe_overflow();
	case EXCEPTION_FLT_STACK_CHECK:
		throw fe_stack_check();
	case EXCEPTION_FLT_UNDERFLOW:
		throw fe_underflow();
	}
}

void enable_fp_exceptions()
{
	_se_translator_function func = _set_se_translator(se_fe_trans_func);
	printf("_se_translator_function: %p\n",func);

	_controlfp(0,_MCW_EM);
}